<template>
<div class="user-box">
  <div class="user" v-if="this.$store.state.userid">
    <img class="avatar" :src="$store.state.avatar" alt="img">
    <div class="userinfo">
      <p class="name">{{ $store.state.username }}</p>
      <p class="count">您有{{$store.state.userlist.length}}个红包正在进行中</p>
    </div>
  </div>
  <div class="userlist" >
    <ul>
      <li v-for="(item,index) in $store.state.userlist" :key="item.uid">
        <div class="text-box">
          <i class="iconfont">&#xe608;</i>
          <span>{{item.text}}</span>
        </div>
        <div class="time-box">
          <span>{{item.datetime | formatTime}}</span>
          <i class="iconfont" @click="deleteOption(item.uid,index)">&#xe615;</i>
        </div>
      </li>
    </ul>
  </div>
  <section class="ui-notice" v-if="!this.$store.state.userid">
    <div class="login">
      <button class="ui-btn" @click="login">点击登录</button>
    </div>
  </section>
  <deletebtn v-if="$store.state.deleteMask"/>
</div>
</template>

<script>
import {format} from '@/utils'
import deletebtn from '@/components/deletebtn'

export default {
  name: 'login',
  props: {
    msg: String
  },
  components:{
    deletebtn
  },
  filters:{
    formatTime(value){
      return format(value)
    }
  },
  data(){
    return{
    }
  },
  methods:{
    login(){
      this.$store.commit('loginMask',!this.$store.state.login)
    },
    deleteOption(id,index){
      this.$store.commit('deleteMaskState',{mark:index,off:true,del:id})

    }
    
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.user-box,.ui-notice{
    width: 100%;
    height: calc(100% - 95px);
    top: 50px;
}
.user{
  width: 86%;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  padding: 20px 0;
  margin-top: 10px;
  border-bottom: .6px solid rgba(184, 179, 179, 0.345);
  .avatar{
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0 10px;
  }
  .userinfo{
    margin-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    .name{
      font-size: 17px;
      // font-weight: bold;
      color: #333;
    }
    .count{
      font-size: 15px;
      color: rgba(128, 122, 122, 0.705);
    }
  }

}
.userlist{
  width: 86%;
  margin: 0 auto;
  padding: 20px 0;
  ul{
    font-size: 15px;
    :nth-child(odd){
      background: rgba(206, 200, 200, 0.205);
    }
    :nth-child(even){
      background: rgba(241, 238, 238, 0.493);
    }
    li{
      padding: 1em 0;
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      color: rgba(128, 121, 121, 0.771);
      .text-box,.time-box{
        background: transparent;
        padding: 0 .5em;
        span{
          padding: 0 .8em;
          background: transparent;
        }
        .iconfont{
          padding: 0 .5em;
          background: transparent;
          font-size: 18px;
        }
      }
    }
  }

}
</style>
